Stochastic Matrices

randStochastic

RandomMatrix.randStochasticFunction
randStochastic(n; type, norm)
  • n: dimension
  • type : default type = 3, 3 for doubly randStochastic, 1 for row, 2 for column stochastic
  • norm : default false, if set to true, the matrix will be normalized by $\sqrt{n}$ (not a typo)

Examples

Generates a 3 by 3 random doubly stochastic matrix

julia> randStochastic(3)

3×3 Matrix{Float64}:
 0.132593  0.216041  0.651367
 0.484097  0.320777  0.195126
 0.261495  0.537825  0.20068

Generates a 3 by 3 normalized random column stochastic matrix

julia> randStochastic(3,type=2,norm=true)

3×3 Matrix{Float64}:
 0.583396  0.608739  0.732921
 0.672821  0.078786  0.302657
 0.475834  1.04453   0.696473
source

Some Random Matrix Theory

using Plots, RandomMatrix, LinearAlgebra
N = 500
colors = [:red,:green,:blue,:purple]
@gif for n = (1:50...,51:10:N...,N:-10:51...,50:1...)

    randStochastic(n,norm=true)|>eigvals|>x->scatter(x,ratio=1,xlims=(-1.5,1.5),title="Circular Law for Stochastic Matrices",size=(600,600),label = "n = $(n)")

    plot!([exp(θ*im) for θ=0:0.01:2pi],label="",lw=3,c=[rand(colors) for _=0:0.01:2pi])

end